﻿using System.Diagnostics;
using DimensionsHelper.Common.Contracts.Excel;

namespace DimensionsHelper.Services.DataCollector;

[DebuggerDisplay("Data = {Data}")]
public struct ExcelDataValue(decimal data, string numberFormat, ExcelStyleColor color)
{
    public const string DefaultNumberFormat = "general";
    
    public
#if NET8_0_OR_GREATER
        readonly
#endif
        bool IsEmpty => Data == null;
    
    public decimal? Data { get; set; } = data;

    public string NumberFormat { get; private set; } = numberFormat;

    public ExcelStyleColor Color { get; private set; } = color;

    public void Copy(ExcelDataValue dataValue)
    {
        Data = dataValue.Data;
        NumberFormat = dataValue.NumberFormat;
        Color = dataValue.Color;
    }


    public static decimal operator -(ExcelDataValue left, ExcelDataValue right)
    {
        decimal leftValue = left.Data ?? 0;
        decimal rightValue = right.Data ?? 0;
        return leftValue - rightValue;
    }

    public static decimal operator +(ExcelDataValue left, ExcelDataValue right)
    {
        decimal leftValue = left.Data ?? 0;
        decimal rightValue = right.Data ?? 0;
        return leftValue + rightValue;
    }
        
}